class Dog():
    "一次模拟小狗的简单尝试"
    def __init__(self, name, age):
        "初始化属性name和age"
        self.name = name
        self.age = age
    def sit(self):
        "模拟小狗蹲下"
        print(self.name.title()+" is now sitting")
    def roll_over(self):
        "打滚"
        print(self.name.title()+" rolled over")

my_dog = Dog('lapu', 6)
print("my dog's name is "+my_dog.name.title()+".")
print("my dog is "+str(my_dog.age)+"years old")

my_dog.sit()
my_dog.roll_over()

class Car():
    "模拟汽车的简单尝试"
    def __init__(self, make, model, year):
        "初始化描述汽车属性"
        self.make = make
        self.model = model
        self.year = year
    def get_descriptive_name(self):
        "返回整洁的描述信息"
        long_name = str(self.year)+' '+self.make+' '+self.model
        return long_name.title()
my_new_car = Car('audi', 'a4', 2016)
print(my_new_car.get_descriptive_name())

# 给属性指定默认值
class Car():
    def __init__(self, make, model, year):
        "初始化描述汽车属性"
        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0
    def get_descriptive_name(self):
        "返回整洁的描述信息"
        long_name = str(self.year) + ' ' + self.make + ' ' + self.model
        return long_name.title()
    def read_odometer(self):
        "打印汽车里程消息"
        print("this car has "+str(self.odometer_reading)+" milses on it")
my_new_car = Car('audi', 'a4', 2016)
print(my_new_car.get_descriptive_name())
my_new_car.read_odometer()

# 修改属性值
my_new_car.odometer_reading = 23
my_new_car.read_odometer()


# 子类方法继承
class ElectricCar(Car):
    def __init__(self, make, model, year):
        "初始化父类属性"
        super().__init__(make, model, year)
        # 重写父类的方法
    def get_descriptive_name(self):
        print("99999")
my_telsar = ElectricCar('telar', 'models', 2016)
print("打印子类。。。。。")
print(my_telsar.get_descriptive_name())


